package com.example.pattern.proxy;

/**
 * 代理类
 *
 * @author FM_南风
 * @date 2024/6/25 13:30
 */
public class Proxy implements Subject {
    private RealSubject realSubject;
    @Override
    public void request() {
        if (realSubject == null) {
            realSubject = new RealSubject();
        }
        preRequest();
        realSubject.request();
        postRequest();
    }

    private void preRequest() {
        System.out.println("代理类: 前置处理");
    }

    private void postRequest() {
        System.out.println("代理类: 后置处理");
    }
}
